package com.hundsun.yr.universal.library.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.hundsun.yr.universal.library.R;



/**
 * @Title: HSToast.java 
 * @Description: 自定义的Toast
 * @date 2015-11-11 下午2:12:37 
 * @author:hejun.shen
 * @email:shenhj15971@hundsun.com 
 * @replace author:
 * @replace date:
 * @version V1.0   
 */
@SuppressLint("ShowToast") 
public class HSToast {
	

	
	
	private Toast   mToast;
    private Context context;

    public HSToast(Context context) {
        this.context = context.getApplicationContext();
    }
    
    /**
     * 显示自定义toast
     * @param tvString 显示的
     * @param imgid  icon地址
     */
    public void showCustomToast(String tvString,int imgid){  
    	showSingletonToast(tvString);
//        View layout = LayoutInflater.from(context).inflate(R.layout.view_toast,null);  
//        TextView text = (TextView) layout.findViewById(R.id.toast_tv);  
//        ImageView mImageView = (ImageView) layout.findViewById(R.id.toast_iv); 
//        mImageView.setBackgroundResource(imgid);  
//        text.setText(tvString);  
//        mToast = new Toast(context);  
//        mToast.setGravity(Gravity.CENTER_VERTICAL,0,0);  
//        mToast.setDuration(Toast.LENGTH_LONG);  
//        mToast.setView(layout);  
//        mToast.show();  
    }  
    
    public void showCustomToast(String tvString){  
    	showCustomToast(tvString,R.drawable.toast_finish);
    }  
    
    public Toast getSingletonToast(int resId) {
        if (mToast == null) {
            mToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
        }else{
            mToast.setText(resId);
        }
        return mToast;
    }

    public Toast getSingletonToast(String text) {
        if (mToast == null) {
            mToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        }else{
            mToast.setText(text);
        }
        return mToast;
    }

    public Toast getSingleLongToast(int resId) {
        if (mToast == null) {
            mToast = Toast.makeText(context, resId, Toast.LENGTH_LONG);
        }else{
            mToast.setText(resId);
        }
        return mToast;
    }

    public Toast getSingleLongToast(String text) {
        if (mToast == null) {
            mToast = Toast.makeText(context, text, Toast.LENGTH_LONG);
        }else{
            mToast.setText(text);
        }
        return mToast;
    }

    public Toast getToast(int resId) {
        return Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    }

    public Toast getToast(String text) {
        return Toast.makeText(context, text, Toast.LENGTH_SHORT);
    }

    public Toast getLongToast(int resId) {
        return Toast.makeText(context, resId, Toast.LENGTH_LONG);
    }

    public Toast getLongToast(String text) {
        return Toast.makeText(context, text, Toast.LENGTH_LONG);
    }

    public void showSingletonToast(int resId) {
        getSingletonToast(resId).show();
    }


    public void showSingletonToast(String text) {
        getSingletonToast(text).show();
    }

    public void showSingleLongToast(int resId) {
        getSingleLongToast(resId).show();
    }


    public void showSingleLongToast(String text) {
        getSingleLongToast(text).show();
    }

    public void showToast(int resId) {
        getToast(resId).show();
    }

    public void showToast(String text) {
        getToast(text).show();
    }

    public void showLongToast(int resId) {
        getLongToast(resId).show();
    }

    public void showLongToast(String text) {
        getLongToast(text).show();
    }
	
}
